import Vue from 'vue'
import Router from 'vue-router'
import App from './App.vue'
// import router from './router'
import routes from './router'
import store from './store'
// createApp(App).use(store).use(router).mount('#app') 
let router
// vue实例变量
let instance = null;
// render 函数
function render(props) {
  if (props) {
    console.log(props);
  }
  router = new Router({
    base: '/vue2',
    mode: 'history',
    routes
  })
  let { container } = props
  // 创建vue实例
  instance = new Vue({
    router,
    store,
    render: (h) => h(App),
  }).$mount(container ? container.querySelector('#app') : "#app");
}
// 是否使用了qiankun
if (window.__POWERED_BY_QIANKUN__) {
  // 路径动态配置
  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
} else {
  // 未使用qiankun 调用render 函数创建vue
  render();
}
// 需要暴露接入协议
// 子组件的协议，必须暴露三个函数
export async function bootstrap(props) {
  console.log('bootstrap函数:', props)
}
export async function mount(props) {
  console.log('mount函数:', props)
  render(props)
}
export async function unmount(props) {
  console.log('unmount函数:', props)
  instance.$destroy()
} 